package com.dragon.pear.pages.tabs.main.sample;

import com.chris.dev.base.libs.v1.http.params.NoneParam;
import com.chris.libs.base.x.mvpp.mvpp.DefaultPresenter;
import com.dragon.pear.api.perfect.MockApi;
import com.dragon.pear.base.http.SuccessNetCallback;
import com.dragon.pear.models.mock.MockUserItemResult;
import com.dragon.pear.models.mock.PageResult;

import javax.inject.Inject;

/**
 * @author Chris Chan
 * Create on： 2025-09-10 09:05
 * Use for: Sample 业务逻辑处理
 * Explain:
 */
public class SamplePresenter extends DefaultPresenter<SampleContract.UIView>
        implements SampleContract.Presenter {
    // 数据中心
    private SampleViewModel viewModel;

    // Dagger2注入构造方法
    @Inject
    public SamplePresenter() {
    }

    // 传入数据中心
    public void setViewModel(SampleViewModel viewModel) {
        this.viewModel = viewModel;
    }

    // 实例方法，一般由ViewProxy主动调用，必须在契约接口中定义
    @Override
    public void requestAndUpdate() {
        this.viewModel.setInfo("演示: 请求并更新的数据");
    }

    @Override
    public void getUserMockItemList() {
        // 获取模拟数据
        MockApi.getUserMockItemList(NoneParam.none(), new SuccessNetCallback<PageResult<MockUserItemResult>>() {
            @Override
            protected void onSuccess(PageResult<MockUserItemResult> data) {
                viewModel.setMockDataList(data.getDataList());
            }
        });
    }
}
